trigger NATOOppUpdateApprovalTrigger on Opportunity (before insert)
{
List<Id> lstaccId=new List<Id>();
Map<Id,Id> MapAccteam=new Map<Id,Id>();
String contractRecId=RecordTypeHelper.GetRecordTypeID('Opportunity', 'Contract');
for(Opportunity opp:trigger.new)
{
lstaccId.add(opp.AccountId);
}
List<AccountTeamMember> allAccTeams = [select AccountId,TeamMemberRole,UserId from AccountTeamMember where AccountId in :lstaccId and TeamMemberRole='GM'];
for(AccountTeamMember accteam:allAccTeams)
{
MapAccteam.put(accteam.AccountId,accteam.UserId);
}
for(Opportunity opp:trigger.new)
{
    if(opp.RecordTypeId==contractRecId && MapAccteam.get(opp.AccountId)!=null)
    {
        opp.Approval_GM__c=MapAccteam.get(opp.AccountId);
    }
}

}